package com.zxjbyte.yiyi.framework.requestlog.config;

import com.zxjbyte.yiyi.framework.requestlog.aspect.RequestLogAspect;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @Author zhangxingjia
 * @Date 2023/3/9 11:15
 * @Version: 1.0
 */
@AutoConfiguration
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
@ConditionalOnProperty(value = RequestLogProperties.REQUEST_LOG_PROPS_PREFIX + ".enabled", havingValue = "true", matchIfMissing = true)
@EnableConfigurationProperties(RequestLogProperties.class)
public class YiyiRequestLogAutoConfiguration {

    @Bean
    public RequestLogAspect requestLogAspect(RequestLogProperties properties){
        return new RequestLogAspect(properties);
    }
}
